package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.PageRecv;
import com.gxa.common.R;


import com.gxa.pojo.Car;
import com.gxa.pojo.Documentary;

import com.gxa.service.CarService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;



/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/08 18:22
 * Description:
 * Version: V1.0
 */
@Controller
@Api(value = "数据test",tags = "车辆数据接口API-张剑宇")

@RequestMapping("/car")
public class CarController {

    @Autowired(required = false)
    private CarService carService;

    //1.车辆搜索查询
    @RequestMapping(value = "/findCarList",method = RequestMethod.POST)
    @ApiOperation(value = "跟单查询接口",notes = "传递当前页码数和每页显示记录数和查询实体对象",httpMethod = "POST", response = JsonResult.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult findCarList(@RequestBody @ApiParam(name = "pageRecv",value = "页面实体",required = true)PageRecv<Car> pageRecv){
        JsonResult<Car> r=carService.findCarList(pageRecv);

        return r;
    }
//    //2.跟单主页面搜索
//    @RequestMapping(value = "/searchDocumentaryList",method = RequestMethod.POST)
//    @ApiOperation(value = "跟单搜索接口",notes = "传递当前页码数和每页显示记录数和条件",httpMethod = "POST", response = JsonResult.class)
//    @ApiImplicitParams({
//
//            @ApiImplicitParam(name = "condition",value = "想要删除跟单数据的条件",dataType = "String",paramType = "query",required = true),
//            @ApiImplicitParam(name = "pageSize",value = "页面数量",dataType = "Integer",paramType = "query",required = true),
//            @ApiImplicitParam(name = "currentPage",value = "当前页数",dataType = "Integer",paramType = "query",required = true),
//            @ApiImplicitParam(name = "employee_name",value = "跟单人",dataType = "String",paramType = "query",required = true),
//    })
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=400,message="坏请求"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=405,message="Method请求错误"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public JsonResult searchDocumentaryList(@RequestParam (name = "condition",required = true)Object condition,@RequestParam (name = "pageSize",required = true)Integer pageSize,@RequestParam (name = "currentPage",required = true)Integer currentPage,@RequestParam (name = "employee_name",required = true)String employee_name){
//
//        JsonResult<Documentary> r=documentaryService.searchDocumentaryList(condition,pageSize,currentPage,employee_name);
//
//        return r;
//    }
//    //2.跟单主页面高级搜索
//    @RequestMapping(value = "/searchDocumentaryListByCondition",method = RequestMethod.POST)
//    @ApiOperation(value = "跟单搜索接口",notes = "传递当前页码数和每页显示记录数和搜索条件对象",httpMethod = "POST", response = JsonResult.class)
//
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=400,message="坏请求"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=405,message="Method请求错误"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
//    @ResponseBody
//    public JsonResult searchDocumentaryListByCondition(@RequestBody @ApiParam(name = "pageRecv",value = "页面实体",required = true)PageRecv<Documentary> pageRecv){
//
//        JsonResult<Documentary> r=documentaryService.searchDocumentaryListByCondition(pageRecv);
//
//        return r;
//    }
//
    //4.车辆数据删除
    @RequestMapping(value = "/deleteCar",method = RequestMethod.POST)
    @ApiOperation(value = "车辆数据删除接口",notes = "传递想要删除车辆数据的id",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({

            @ApiImplicitParam(name = "car_id",value = "想要删除跟单数据的id",dataType = "String",paramType = "query",required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteDocumentary(@RequestParam(name = "car_id",required = true) Integer car_id){
        R r=carService.deleteCar(car_id);

        return r;
    }

    //5.汽车数据添加
    @RequestMapping(value = "/addCar",method = RequestMethod.POST)
    @ApiOperation(value = "增加跟单数据接口",notes = "跟单数据实体json格式",httpMethod = "POST", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addCar(@RequestBody @ApiParam(name = "car",value = "车辆数据实体",required = true) Car car ){
        R r=carService.addCar(car);


        return r;
    }

    //6.车辆数据修改
    @RequestMapping(value = "/updateCar",method = RequestMethod.POST)
    @ApiOperation(value = "修改车辆数据接口",notes = "车辆数据实体json格式",httpMethod = "POST", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateDocumentary(@RequestBody @ApiParam(name = "car",value = "跟单数据实体",required = true) Car car ){
        R r=carService.updateCar(car);

        return r;
    }


}
